package gui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;

import application.GameManager;

public class EnterNameFrame extends JFrame implements ActionListener{
	
	private GameManager _manager;
	private JTextArea _nameTextArea;
	
	public EnterNameFrame(GameManager manager){
		super("Enter name!");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this._manager = manager;
		this.getContentPane().setLayout(new BorderLayout());
		JLabel text = new JLabel("You've entered the High Score!");
		this._nameTextArea = new JTextArea("Enter name");
		JButton okButton = new JButton("OK");
		okButton.addActionListener(this);
		this.getContentPane().add(text,BorderLayout.NORTH);
		this.getContentPane().add(this._nameTextArea,BorderLayout.CENTER);
		this.getContentPane().add(okButton,BorderLayout.SOUTH);
		this.setSize(200, 100);
		this.setVisible(true);
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		this.setVisible(false);
		new HighScoreFrame(_manager, this._nameTextArea.getText());
	}
}
